package com.sphd.beautysalon.model;


import com.android.volley.VolleyError;
import com.sphd.beautysalon.interfaces.VolleyJsonObjectCallBack;
import com.sphd.beautysalon.presenter.AddManagerPresenterImpl;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by Hu on 2016/11/09
 */

public class AddManagerModelImpl implements AddManagerModel, VolleyJsonObjectCallBack {
    AddManagerPresenterImpl addManagerPresenter;

    @Override
    public void senUrl(String url, AddManagerPresenterImpl addManagerPresenter) {
        volleyUtil.setJsonObjectRequest(url, this);
        this.addManagerPresenter = addManagerPresenter;
    }

    @Override
    public void onResponse(JSONObject response) {
        try {
            int res = response.getInt("res");
            addManagerPresenter.sendRes(res);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onErrorResponse(VolleyError error) {
        addManagerPresenter.sendError(error);
    }
}